class Solution {
    public static void main(String[] args) {

    }

    public int minimumDeleteSum(String s1, String s2) {
          int n = s1.length() ;
          int m = s2.length() ;
          s1 = " "+s1 ;
          s2 = " "+s2 ;
          char[] a1 = s1.toCharArray() ;
          char[] a2 = s2.toCharArray() ;
          int[][] dp = new int[n+1][m+1];
          for(int i=1 ; i<= n ; i ++){
            for(int j=1 ; j <= m ; j ++){
                dp[i][j] = a1[i]==a2[j] ? dp[i-1][j-1]+a1[i] : 0 ;
                dp[i][j] = Math.max(dp[i][j] , Math.max(dp[i-1][j] , dp[i][j-1])) ;
            }
          }
           int sum = 0 ; 
           for(int i=1 ; i<=n;  i ++){
             sum += a1[i];
           }
           for(int i=1 ; i<=m ; i ++){
            sum += a2[i];
           }
          return sum -dp[n][m]*2 ;
    }
}